package com.sc.service.impl.patrol;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.domain.patrol.PatrolProject;
import com.sc.dto.PatrolProjectDTO;
import com.sc.mapper.patrol.PatrolProjectMapper;
import com.sc.service.patrol.PatrolProjectService;
import com.sc.vo.PatrolProjectVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/*
 * 巡检项目
 * @author: Zuiliu
 * 添加服务层实现类
 * */
@Service
public class PatrolProjectServiceImpl extends ServiceImpl<PatrolProjectMapper, PatrolProject> implements PatrolProjectService {

    @Override
    public Page<PatrolProjectVO> pageQuery(PatrolProjectDTO patrolProjectDTO) {
        QueryWrapper<PatrolProject> wrapper = new QueryWrapper<>();
        wrapper.like("project_name", patrolProjectDTO.getProjectName());

        Page<PatrolProject> page = new Page<>(patrolProjectDTO.getPageNum(), patrolProjectDTO.getPageSize());
        Page<PatrolProject> patrolProjectPage = page(page, wrapper);
        Page<PatrolProjectVO> patrolProjectVOPage = new Page<>();

        BeanUtils.copyProperties(patrolProjectPage, patrolProjectVOPage);
        return patrolProjectVOPage;
    }
}
